package br.edu.fanor.processabatch.main;

import java.io.FileWriter;

import br.edu.fanor.processabatch.entity.Dependente;
import br.edu.fanor.processabatch.entity.Servidor;
import br.edu.fanor.processabatch.entity.VinculoFuncional;
import br.edu.fanor.processabatch.utils.ArquivoUtils;
import br.edu.fanor.processabatch.utils.EntitysFactoryUtils;

public class GeraArquivo implements Runnable{
	
	private FileWriter fw;

	@Override
	public void run() {
		
		for (int i = 0; i < 20000; i++) {
			
			Servidor servidor = EntitysFactoryUtils.getServidor();
			Dependente dependente = EntitysFactoryUtils.getDependente(servidor);
			VinculoFuncional vinculo = EntitysFactoryUtils.getVinculoFuncional(servidor);		
			
			String dados = servidor+"\r\n"+dependente+"\r\n"+vinculo;
			
			ArquivoUtils.escrever(getFileWriter(), dados);
		
		}	
		
	}
	
	public void setFileWriter(FileWriter fw){
		this.fw = fw;
	}
	public FileWriter getFileWriter(){
		return this.fw;
	}

}
